package client;

import bean.User;
import dao.UserDao;
import dao.impl.UserDaoImpl;
import org.omg.CORBA.PUBLIC_MEMBER;
import service.impl.UserServiceImpl;


import java.sql.SQLException;
import java.text.ParseException;
import java.util.Scanner;

import static client.MnueClient.showMnueList;

/**
 * 宿舍管理系统，客户端登录
 */
public class LoginClient {

    private static UserServiceImpl userService = new UserServiceImpl();


    public void Login() throws SQLException, ParseException {

        System.out.println("------------欢迎进入宿舍管理系统-----------");
        Scanner in = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = in.next();
        System.out.println("请输入密码：");
        String password = in.next();
        System.out.println("请输入身份信息：");
        int role = in.nextInt();
        //获取到用户输入的用户名、密码、角色
        //查询用户表，校验用户信息
        int code = userService.regexLoginInfo(username, password, role);

        if (code == 200) {
            //登录成功，展示菜单列表
            showMnueList(role);
            //获取用户输入的指令
        } else if (code == 1) {
            System.out.println("用户不存在");
        } else {
            System.out.println("系统错误");
        }
    }

    public static void main(String[] args) throws SQLException, ParseException {
        LoginClient lc = new LoginClient();
        lc.Login();
    }
}





